package com.hnyfkj.jyindustry.biz.area.service.impl;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnyfkj.jyindustry.biz.area.dao.AreaDao;
import com.hnyfkj.jyindustry.biz.area.dto.AreaReturnDto;
import com.hnyfkj.jyindustry.biz.area.entity.Area;
import com.hnyfkj.jyindustry.biz.area.service.AreaService;

/**
 * @ClassName: AreaDao
 * @Description: 地区信息
 * @author zhujq
 * @date 2021年3月6日 下午12:58:51 
 */
@Service
public class AreaServiceImpl extends ServiceImpl<AreaDao, Area> implements AreaService {
		
	@Autowired
	private AreaDao areaDao;
	
	@Override
	public List<Area> getList(String areaId) {
		QueryWrapper<Area> qw = new QueryWrapper<>();
		if(StringUtils.isNotBlank(areaId)) {
			qw.eq("pid", areaId);
		}
		//qw.gt("area_level", "3");
		qw.orderByAsc("sort");
		List<Area> list = this.list(qw);
		return list;
	}

	@Override
	public Area getOneById(String areaId) {
		QueryWrapper<Area> qw = new QueryWrapper<>();
		if(StringUtils.isNotBlank(areaId)) {
			qw.eq("area_id", areaId);
		}
		return this.getOne(qw);
	}

	@Override
	public List<AreaReturnDto> getAreaList(String upAreaId) {
		QueryWrapper<Area> qw = new QueryWrapper<>();
		if(StringUtils.isNotBlank(upAreaId)) {
			qw.eq("up_area_id", upAreaId);
		}
		qw.orderByAsc("sort_no");
		List<AreaReturnDto> list = areaDao.getAreaList(upAreaId);
		return list;
	}

	@Override
	public List<AreaReturnDto> getAreaBySql(String sql) {
		return areaDao.getAreaBySql(sql);
	}
}
